<?php if($debitMemoForm->isNew()):?>
  <?php $void = 'N'?>
  <div id="debitMemoPanel">
  <div class="form_title">New Debit Memo for <?php echo $contact->getListName() ?></div>
<?php else:?>
  <?php $void = $debitMemoForm->getObject()->getDocument()->getVoid()?>
  <div id="debitMemoFormDiv">
  <div class="form_title">View Debit Memo for <?php echo $contact->getListName().($void=='Y'?', DEBIT MEMO IS VOID.':''); ?></div>
<?php endif;?>
  <?php echo form_tag_for($debitMemoForm,$debitMemoForm->getUrl(),array('id'=>'debitMemoForm',)); ?>
    <font color="#FF0000"><?php echo $error_message?></font>
    <table>
      <tr>
        <td class="container box">
          <?php include_partial('debit_form',array('documentForm'=>$documentForm,'debitMemoForm'=>$debitMemoForm,'invoice'=>$invoice,))?>
        </td>
      </tr>
    </table>
    <?php if ($void=='N'):?>
    <center>
      <?php if(! $debitMemoForm->isNew()):?>
        <input type="button" value="Void" id="debitMemoButtonVoid"/>
        <script language="javascript">
          $(document).ready(
            function(){
              $('#debitMemoButtonVoid').click(
                function(e){
                  $.get(
                    'actionVerifier/verify',
                    {
                      'task':'debitMemoVoid',
                      'debit_iden':"<?php echo $debitMemoForm->getObject()->getDebitIden()?>",
                      'callback':'debitMemoVoidSuccess',
                      'cancel_callback':'debitMemoVoidSuccess({"debit_iden":"<?php echo $debitMemoForm->getObject()->getDebitIden()?>"},\'\')',
                      'prompt':"Void Debit Memo# <?php echo $debitMemoForm->getObject()->getDebitId()?>",
                    },
                    function(content){
                      $('#debitMemoPanel').html(content);
                    }
                  );
                }
              );
            }
          );
        </script>
      <?php else:?>
        <input type="submit" value="Save"/> |
        <input type="reset" value="Reset"/>
      <?php endif;?>
    </center>
    <?php endif;?>
  </form>
</div>

<?php if ($void=='N'):?>
<script language="javascript">
  $(document).ready(
    function(){
      $('#debitMemoForm').submit(
        function(){
          showStatusWindow();
          $(this).ajaxSubmit(
            {
              type: 'post',
              dataType: 'html',
              success: 
              function(data,statusText){
                <?php if($debitMemoForm->isNew()):?>
                $('#debitMemoPanel').html(data);
                <?php else:?>
                $('#debitMemoFormDiv').html(data);
                <?php endif;?>
                hideStatusWindow();
              },
            }
          );
          return false;
        }
      );
    }
  );
</script>
<?php endif;?>